使用JavaScript更改CSS偽元素


Posted by hoyi-23 on 2021-06-17

這裡提供一個很簡單的作法:

HTML

<div class="box" some-attribute-name=""></div>

CSS

.box::before{
    content= attr(some-attribute-name);
}

JavaScript

var box = document.querySelector('.box');
box.setAttribute('some-attribute','要新增的屬性值');

#偽元素 #javascript







Related Posts

滲透測試重新打底(4)--Exploitation初介紹與密碼爆破

滲透測試重新打底(4)--Exploitation初介紹與密碼爆破

Day3 讓我見識一下吧,終端機的性能

Day3 讓我見識一下吧,終端機的性能

關於 React 小書:做出 React

關於 React 小書:做出 React


Comments